Skip to content

Fix: throw error when dbAdapter is missing (closes #967)#970

Open
divyanshsaraswat wants to merge 1 commit into
hoodiehq:masterfrom
divyanshsaraswat:db-adapter_validation
Open

Fix: throw error when dbAdapter is missing (closes #967)#970
divyanshsaraswat wants to merge 1 commit into
hoodiehq:masterfrom
divyanshsaraswat:db-adapter_validation

Conversation

@divyanshsaraswat

@divyanshsaraswat divyanshsaraswat commented Dec 21, 2025

Copy link
Copy Markdown

Problem
While working with Hoodie, I noticed that if the dbAdapter option is missing or undefined (and you aren't using an external dbUrl or inMemory mode), the application can crash or fail with obscure errors later in the initialization process.

Current Behavior
Currently, the CLI does not validate that a dbAdapter is explicitly present if other database options are missing. This can lead to runtime errors when the application attempts to use the undefined adapter.

Expected Behavior
The application should check for a valid dbAdapter configuration during startup and throw a clear, descriptive error message if it is missing, guiding the user to fix their configuration.

Proposed Solution
I’ve implemented a fix in my fork that:

  1. Adds a defensive check in : cli/options.js to ensure dbAdapter is defined when not using inMemory or dbUrl.
  2. Throws a specific error: "dbAdapter option is required when not using in-memory or external database URL."
  3. Adds a unit test: in test/unit/cli/options-test.js to verify this error handling works as expected.

Fork comparison: Link to the fork

I’d like to open a pull request if this approach looks good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant